#include <iostream>
#include <algorithm>
#include <cstdio>
#include <array>
#include <queue>
#include <vector>
#include <bitset>
using namespace std;
#ifdef ONLINE_JUDGE

//#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[1 << 23], *p1 = buf, *p2 = buf, ubuf[1 << 23], *u = ubuf;

#endif
int read() {
	int p = 0, flg = 1;
	char c = getchar();
	while (c < '0' ||c > '9') {
		if (c == '-') flg = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		p = p * 10 + c - '0';
		c = getchar();
	}
	return p * flg;
}
void write(int x) {
	if (x < 0) {
		x = -x;
		putchar('-');
	}
	if (x > 9) {
		write(x / 10);
	}
	putchar(x % 10 + '0');
}
bool _stmer;

const int N = 1.5e6 + 5, M = 3e6 + 5, mod = 1e9 + 7;

namespace G {

array <int, N> fir;
array <int, M> nex, to;

int cnt = 1;

void add(int x, int y) {
	cnt++, nex[cnt] = fir[x];
	to[cnt] = y, fir[x] = cnt;
}

} //namespace G

namespace Subtask1 {

array <int, N> dis, vis;
queue <int> q;

void bfs(int x, int n, int S) {
	for (int i = 1; i <= n; i++)
		dis[i] = -1, vis[i] = 0;
	q.push(x), dis[x] = 0;
	while (!q.empty()) {
		int u = q.front(); q.pop();
		if (S & (1 << (u - 1))) vis[u]++;
		for (int i = G::fir[u]; i; i = G::nex[i]) {
			if (~dis[G::to[i]]) continue;
			dis[G::to[i]] = dis[u] + 1, q.push(G::to[i]);
			vis[G::to[i]] = vis[u];
		}
	}
}

array <vector <int>, N> isl;

void main(int n, int k) {
	for (int i = 2; i <= n; i++) {
		int x = read(), y = read();
		G::add(x, y), G::add(y, x);
	}
	int ans = 0;
	for (int S = 0; S < 1 << n; S++) {
		bool flg = 1;
		for (int i = 1; i <= n; i++) {
			bfs(i, n, S);
			for (int j = 1; j <= n; j++)
				if (dis[j] == k - 1) flg = flg & (vis[j] == 1);
			if (!flg) break;
		}
		ans += flg;
	}
	if (ans) puts("YES");
	else puts("NO");
	write(ans), puts("");
}

} //namespace Subtask1

void Mod(int &x) {
	if (x >= mod) x -= mod;
	if (x < 0) x += mod;
}

namespace Subtask2 {

void main(int n, int k) {
	for (int i = 2; i <= n; i++) {
		int x = read(), y = read();
		G::add(x, y), G::add(y, x);
	}
	puts("YES");
	write(k), puts("");
}

} //namespace Subtask2

bool _edmer;
int main() {
	cerr << (&_stmer - &_edmer) / 1024.0 / 1024.0 << "MB\n";
#ifndef cxqghzj
	freopen("life.in", "r", stdin);
	freopen("life.out", "w", stdout);
#endif
	int n = read(), k = read();
	if (n <= 18) Subtask1::main(n, k);
	else Subtask2::main(n, k);
	return 0;
}
